package com.cloud.lawcase.api.provider;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class TcDicLawCauseProvider {
	private static final String LIST_PAGE_SELECT = "t1.cause_id, t1.cause_code, t1.cause_name, t1.law_id, t1.item_id, t1.is_punish, t1.excute_type_id, t2.excute_type_name",
			LIST_PAGE_FOMR = "tc_dic_law_cause t1 left join tc_dic_law_excute_type t2 on t1.excute_type_id = t2.excute_type_id";

	public String listCauseByLawAndExcute(@Param("lawId")long lawId, @Param("excuteTypeId")int excuteTypeId) {
		SQL sql = new SQL().SELECT(LIST_PAGE_SELECT).FROM(LIST_PAGE_FOMR);
		sql.WHERE("t1.law_id = #{lawId}");
		if (excuteTypeId > 0) {
			sql.WHERE("t1.excute_type_id = #{excuteTypeId}");
		}
		return sql.toString();
	}
}
